'use strict';

new Vue({
  el: '#login-block',
  data: {
    user_id: null,
    email: null,
  },
  created() {
    this.getUser();
  },
  methods: {
    getUser() {
      const that = this;
      $.ajax({
        url: '../getUser',
        type: 'GET',
        success(data) {
          console.log(data);
          $.cookie('user_id', data.user_id);
          $.cookie('email', data.email);
          that.user_id = data.user_id;
          that.email = data.email;
        },
      });
    },
    logout() {
      this.user_id = null;
      this.email = null;
      $.ajax({
        url: '../logout',
        type: 'GET',
      });
    },
  },
});
